package com.polytech.web.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.polytech.business.ForumManager;
import com.polytech.model.Topic;
import com.polytech.utils.BusinessFactory;

public class IndexController extends HttpServlet {

	private ForumManager forumManager;
	
	@Override
	public void init() throws ServletException {
		forumManager=BusinessFactory.getForumManager();
	}
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
		List<Topic> listTopics=forumManager.findTheLastThreeTopics();
		req.setAttribute("listTopics", listTopics);
		getServletContext().getRequestDispatcher("/views/index.jsp").forward(req, resp);
	}
}
